home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 2000
/
MacHack 2000.toast
/
pc
/
The Hacks
/
Softshoe
/
Lisa's Mac Parts
/
Views
/
Canvas Loops
/
CanvasLoopBase.cp
< prev
next >
Wrap
Text File
|
2000-06-23
|
2KB
|
108 lines
// CanvasLoopBase.cp
#ifndef CanvasLoopBase_h
#include "CanvasLoopBase.h"
#endif
#ifndef DrawsSpontaneously_h
#include "DrawsSpontaneously.h"
#endif
#ifndef Pane_h
#include "Pane.h"
#endif
#ifndef ConstStackLoop_h
#include "ConstStackLoop.h"
#endif
void CanvasLoopBase::FindFirstPath( const DrawsSpontaneously *position )
{
while ( position != 0 && !position->panes.IsEmpty() )
{
const Pane *up = *position->panes.First();
Assert( up != 0 );
path.Push( up );
position = up->Parent();
}
}
void CanvasLoopBase::AdvancePath()
{
while ( !path.IsEmpty() )
{
const Pane *top = path.Top();
Assert( top != 0 );
if ( top->viewLink.Next() != 0 )
{
const Pane *next = *top->viewLink.Next();
path.Top() = next;
FindFirstPath( next->Parent() );
return;
}
path.Pop();
}
}
void CanvasLoopBase::AdvancePathUntilReachingPort()
{
while ( !path.IsEmpty() && path.Top()->Parent() != 0 )
AdvancePath();
}
void CanvasLoopBase::FindFirstPathToPort( const DrawsSpontaneously *start )
{
FindFirstPath( start );
AdvancePathUntilReachingPort();
}
void CanvasLoopBase::AdvancePathToPort()
{
AdvancePath();
AdvancePathUntilReachingPort();
}
void CanvasLoopBase::BuildCanvas()
{
Assert( !path.IsEmpty() );
Assert( path.Top() != 0 );
Assert( path.Top()->Parent() == 0 );
for ( ConstStackLoop<const Pane *> pathPosition( path );
pathPosition.Unfinished();
pathPosition++ )
{
Assert( *pathPosition != 0 );
(*pathPosition)->Adjust( canvas );
if ( !canvas.Visible() )
break;
}
}
void CanvasLoopBase::AdvanceUntilVisible()
{
for ( ; Unfinished(); AdvancePathToPort() )
{
BuildCanvas();
if ( canvas.Visible() )
return;
canvas.Clear();
}
}
CanvasLoopBase::CanvasLoopBase( const DrawsSpontaneously& view )
{
FindFirstPathToPort( &view );
AdvanceUntilVisible();
}
void CanvasLoopBase::operator++()
{
Assert( Unfinished() );
canvas.Clear();
AdvancePathToPort();
AdvanceUntilVisible();
}